-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IsNull()/IsNotNull() helper extensions #5207
Conversation
96d0bde
to
1f72704
Compare
In #5099, I found such always non-null warning was too aggressive, especially when the nullability can't be fully expressed. |
Ah, I didn't notice this was only a resharper warning. That's a good point. |
The only disable ReSharper offers is a global disable, which we definitely don't want and removes half the purpose of NRT (to simplify and remove null checks). This is a very extreme edge case for us, because we can usually assume the dependency is present in practically all user cases except The only alternative I can provide is to use |
Assuming this means marking dependencies as nullable and using But I guess that can also become a major problem at the same time because it's easy to miss such cases during review and blow up anything by mistake... I don't have a strong opinion on this to be honest, and having |
My two cents:
In light of both views I'm more than fine with these existing, except maybe I'd add a note in the xmldoc (probably in a remarks section) as to why they exist and what the intended usage is. |
The following is a typical usage of binding to events of DI'd members:
I propose the
IsNull()
/IsNotNull()
extension methods in order to bypass the warning insideDispose()
and increase our coverage of NRT. The resultant code becomes: